using UnityEngine;
using System.Collections;
/*
 * THis for object that you can pick up and add to your inventory
 * This script 
 * 1. hold object info 
 * 2. flashes the object on mouse hover
 * 3. invokes the global inveotry method to remove and save the object.
 * */

public class InventoryItem : MonoBehaviour
{
    public Texture2D iconTexture;
    public string itemName = "Put your Object name";
    public string itemTag  = "Put unique tag string here";
    public Inventory inventory; //represents a reference to our inventory

    void OnMouseOver()
    {
	    //~ if( GetComponent<Equippable> != null){
		    //~ if( GetComponent<Equippable>.isEquipped())
			    //~ return;
	    //~ }
         
	    //ToggleAlpha(0.3f, 1.0f);
        Color curcolor = renderer.material.color;
        curcolor.a = Random.value; 

	    if(Input.GetMouseButtonDown(0))
        {
            inventory.GetComponent<Inventory>().inventoryButtonClick = true;
		    curcolor.a = 1;
		    //print ("inventory.SaveObjectInInventory");
            inventory.GetComponent<Inventory>().SaveObjectInInventory(transform.gameObject);	
	    }
        renderer.material.color = curcolor; 
         
    }

    void OnMouseExit(){
	   		Color curcolor = renderer.material.color;
			curcolor.a = 1;
            renderer.material.color = curcolor;
            inventory.GetComponent<Inventory>().inventoryButtonClick = false;
    } 
}